<template>
  <div class="cell" :class="{ active: active }">
    <el-button :type="type" :plain="!active">
      <slot></slot>
      <i
        v-if="closable"
        class="el-icon-close"
        @click="$emit('removeItem', index)"
      ></i>
    </el-button>
  </div>
</template>

<script>
export default {
  props: {
    active: {
      type: Boolean,
      default: false
    },
    index: Number,
    closable: {
      type: Boolean,
      default: true
    }
  },

  computed: {
    type () {
      return this.active ? 'danger' : 'primary'
    }
  }
}
</script>

<style lang="less" scoped>
.cell {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100px;
  // border: 1px solid #aaa;
  margin-right: 5px;
  margin-bottom: 5px;
  &.active {
    transition: 0.5s;
  }
  .el-button {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    padding-left: 10px;
    padding-right: 10px;
    ::v-deep span {
      display: block;
      width: 100%;
      display: flex;
      justify-content: space-between;
    }
  }
  i {
    visibility: hidden;
    font-size: 16px;
  }
  &:hover {
    i {
      visibility: inherit;
    }
  }
}
.cell:nth-child(8n) {
  margin-right: 0;
}
.cell-move {
  transition: transform 0.3s;
}
.cell-enter-active,
.cell-leave-active {
  transition: all 2s;
}
.cell-enter, .cell-leave-to
/* .list-leave-active for below version 2.1.8 */ {
  opacity: 0;
  transform: translateY(30px);
}
</style>
